// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch;

/// <summary>
/// <para>Controls how to deal with unavailable concrete indices (closed or missing), how wildcard expressions are expanded<br/>to actual indices (all, closed or open indices) and how to deal with wildcard expressions that resolve to no indices.</para>
/// </summary>
public sealed partial class IndicesOptions
{
	/// <summary>
	/// <para>If false, the request returns an error if any wildcard expression, index alias, or `_all` value targets only<br/>missing or closed indices. This behavior applies even if the request targets other open indices. For example,<br/>a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("allow_no_indices")]
	public bool? AllowNoIndices { get; set; }

	/// <summary>
	/// <para>Type of index that wildcard patterns can match. If the request can target data streams, this argument<br/>determines whether wildcard expressions match hidden data streams. Supports comma-separated values,<br/>such as `open,hidden`.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("expand_wildcards")]
	[SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.ExpandWildcard))]
	public ICollection<Elastic.Clients.Elasticsearch.ExpandWildcard>? ExpandWildcards { get; set; }

	/// <summary>
	/// <para>If true, concrete, expanded or aliased indices are ignored when frozen.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ignore_throttled")]
	public bool? IgnoreThrottled { get; set; }

	/// <summary>
	/// <para>If true, missing or closed indices are not included in the response.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ignore_unavailable")]
	public bool? IgnoreUnavailable { get; set; }
}

/// <summary>
/// <para>Controls how to deal with unavailable concrete indices (closed or missing), how wildcard expressions are expanded<br/>to actual indices (all, closed or open indices) and how to deal with wildcard expressions that resolve to no indices.</para>
/// </summary>
public sealed partial class IndicesOptionsDescriptor : SerializableDescriptor<IndicesOptionsDescriptor>
{
	internal IndicesOptionsDescriptor(Action<IndicesOptionsDescriptor> configure) => configure.Invoke(this);

	public IndicesOptionsDescriptor() : base()
	{
	}

	private bool? AllowNoIndicesValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.ExpandWildcard>? ExpandWildcardsValue { get; set; }
	private bool? IgnoreThrottledValue { get; set; }
	private bool? IgnoreUnavailableValue { get; set; }

	/// <summary>
	/// <para>If false, the request returns an error if any wildcard expression, index alias, or `_all` value targets only<br/>missing or closed indices. This behavior applies even if the request targets other open indices. For example,<br/>a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.</para>
	/// </summary>
	public IndicesOptionsDescriptor AllowNoIndices(bool? allowNoIndices = true)
	{
		AllowNoIndicesValue = allowNoIndices;
		return Self;
	}

	/// <summary>
	/// <para>Type of index that wildcard patterns can match. If the request can target data streams, this argument<br/>determines whether wildcard expressions match hidden data streams. Supports comma-separated values,<br/>such as `open,hidden`.</para>
	/// </summary>
	public IndicesOptionsDescriptor ExpandWildcards(ICollection<Elastic.Clients.Elasticsearch.ExpandWildcard>? expandWildcards)
	{
		ExpandWildcardsValue = expandWildcards;
		return Self;
	}

	/// <summary>
	/// <para>If true, concrete, expanded or aliased indices are ignored when frozen.</para>
	/// </summary>
	public IndicesOptionsDescriptor IgnoreThrottled(bool? ignoreThrottled = true)
	{
		IgnoreThrottledValue = ignoreThrottled;
		return Self;
	}

	/// <summary>
	/// <para>If true, missing or closed indices are not included in the response.</para>
	/// </summary>
	public IndicesOptionsDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true)
	{
		IgnoreUnavailableValue = ignoreUnavailable;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AllowNoIndicesValue.HasValue)
		{
			writer.WritePropertyName("allow_no_indices");
			writer.WriteBooleanValue(AllowNoIndicesValue.Value);
		}

		if (ExpandWildcardsValue is not null)
		{
			writer.WritePropertyName("expand_wildcards");
			SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.ExpandWildcard>(ExpandWildcardsValue, writer, options);
		}

		if (IgnoreThrottledValue.HasValue)
		{
			writer.WritePropertyName("ignore_throttled");
			writer.WriteBooleanValue(IgnoreThrottledValue.Value);
		}

		if (IgnoreUnavailableValue.HasValue)
		{
			writer.WritePropertyName("ignore_unavailable");
			writer.WriteBooleanValue(IgnoreUnavailableValue.Value);
		}

		writer.WriteEndObject();
	}
}